<template>
	<view class="warp">
	
		<view class="list" >
			<view class="l_text" >提现金额</view>
			<view class="r_box" >
				<input class="input" type="text"  v-model="tnum" maxlength="20" />
			</view>
		</view>
		<view class='tit'>*可提现金额:{{user_balance}},当前手续费:{{pro}}%,提现后请耐心等待,2-3个工作日到账</view>
		<view class="form_btn" @click="save">提交</view>
	</view>
</template>

<script>
	export default {
		
		data() {
			return {
				userinfo:'',
				user_balance:'',
				tnum:'',
				pro:0
			}
		},
		onLoad() {
			
			uni.setNavigationBarTitle({
			    title: '提现'
			});
			this.userinfo=uni.getStorageSync('user');
			this.user_balance=this.userinfo.userGiveMoney?this.userinfo.userGiveMoney:0;
			this.getinfo();
		},
		methods:{
			getinfo(){
				var that=this;
				this.$http.get('user/getTixianPro',{}).
				then(function (response) {
					that.pro=response.data[0];
				}).catch(function (error) {
					console.log(error);
				});
			},
			save(){
				var that=this;
				
				if(this.tnum==''||this.tnum==null||this.tnum==undefined||this.tnum==0||isNaN(this.tnum)){
					uni.showToast({
						icon:'none',
						title:'请输入正确的数量'
					})
					return;
				}
				if(parseFloat(this.tnum)>parseFloat(this.user_balance)){
					uni.showToast({
						icon:'none',
						title:'余额不足'
					})
					return;
				}
				var that=this;
				this.$http.post('user/addTixian',{money:this.tnum}).
				then(function (response) {
					
					uni.showToast({
						icon:'none',
						title:response.msg
					})
					var clock=setInterval(function(){
						clearInterval(clock);
						uni.navigateBack();
					},1500);
					return;
					
				}).catch(function (error) {
					console.log(error);
				});
			}
		}
	}
</script>
<style lang="scss" scoped>
	.warp{
		padding: 0 20rpx;
		.list1{
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid #ebebeb;
			height: 120rpx;
			.t_img{
				width: 90rpx;
				height: 90rpx;
				border-radius: 50%;
			}
			.l_text{
				width: 140rpx;
				font-size: 30rpx;
				color: #454545;
			}
		}
		.list{
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 100rpx;
			border-bottom: 1px solid #ebebeb;
			.l_text{
				width: 140rpx;
				font-size: 30rpx;
				color: #454545;
			}
			.r_box{
				overflow: hidden;
				height: 100%;
				align-items: center;
				display: flex;
				font-size: 30rpx;
				color: #a5a5a5;
				.r_img{
					width: 16rpx;
					height: 30rpx;
				}
				.input{
					font-size: 30rpx;
					text-align: right;
				}
			}
		}
		.form_btn{
			width: 650rpx;
			height: 90rpx;
			border-radius: 45px;
			background: #102d57;
			font-size: 36rpx;
			color: #fff;
			margin: 150rpx auto 0;
			text-align: center;
			line-height: 90rpx;
		}
	}
	.tit{
		font-size: 30rpx;
		color:red;
		margin-top: 20rpx;
	}
</style>
